<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Service\BaseService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;

/**
 * Class IndexController
 * @package App\Controller
 * @Controller()
 */
class IndexController extends AbstractController
{
    /**
     * @Inject()
     * @var BaseService
     */
    protected $baseService;

    public function index()
    {
        $user = $this->request->input('user', 'Hyperf');
        $method = $this->request->getMethod();


        return [
            'method' => $method,
            'message' => "Hello {$user}.",
            'ip' => swoole_get_local_ip()['ens33']
        ];
    }

    /**
     * Notes:Rpc方法调用
     * Author:Liangshan
     * Date:2020/11/11
     * Time:18:59
     * @param
     *
     * @RequestMapping(path="get-micro",methods={"get","post"})
     */
    public function getMicro()
    {
        return $this->baseService->getRpcMicro(3, 5);
    }
}
